package com.luoxiang.socialandroid.adapter

import android.graphics.Color
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.luoxiang.socialandroid.R
import com.luoxiang.socialandroid.bean.VipX

class RechargeAdapter(data: MutableList<VipX>) :
    BaseQuickAdapter<VipX, BaseViewHolder>(R.layout.item_recharge, data) {
    var index: Int = 0

    override fun convert(holder: BaseViewHolder, item: VipX) {
        holder.apply {
            if (item.validMonth > 3) {
                setText(R.id.textView24, context.getString(R.string.mi_zhongshen))
            } else {
                setText(R.id.textView24, item.validMonth.toString() + context.getString(R.string.mi_geyue))
            }
            setText(R.id.tx_priceed, context.getString(R.string.mi_qian) + item.amount)
            setText(R.id.tx_give, context.getString(R.string.mi_zengsong) + item.coin + context.getString(R.string.mi_jinbi))

        }
        if (index == getItemPosition(item)) {
            //选中
            holder.apply {
                Glide.with(context)
                    .load(R.mipmap.icon_chongzhibg)
                    .into(getView(R.id.imageView16))
                getView<ImageView>(R.id.imageView17).visibility = View.VISIBLE
                getView<ImageView>(R.id.imageView18).setImageResource(R.mipmap.icon_cztzbg)
                getView<TextView>(R.id.textView24).setTextColor(Color.parseColor("#ff594322"))
                getView<TextView>(R.id.tx_priceed).setTextColor(Color.parseColor("#ff9e825b"))

            }
        } else {
            //未选中
            holder.apply {
                Glide.with(context)
                    .load(R.mipmap.icon_buxuanzhong11)
                    .into(getView(R.id.imageView16))
                getView<ImageView>(R.id.imageView17).visibility = View.GONE
                getView<ImageView>(R.id.imageView18).setImageResource(R.mipmap.icon_weixuanzhongkuang)
                getView<TextView>(R.id.textView24).setTextColor(Color.parseColor("#FFFFFF"))
                getView<TextView>(R.id.tx_priceed).setTextColor(Color.parseColor("#FFFFFF"))
            }
        }
    }
}